package com.google.code.mamule.user;

import com.google.code.mamule.mail.Mailable;
import com.google.common.base.Objects;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * Created with IntelliJ IDEA. User: borck_000 ; Date: 12/19/13 ; Time: 2:24 PM
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@Entity
public class User {

  @Id
  private String username;
  private String password;
  private String email;
  private String creditCard;

  @OneToOne(cascade = CascadeType.ALL)
  private Mailable identity;

  public User() { /* JAXB */}

  public User(final String username, final String password, final String email,
              final String creditCard,
              final Mailable identity) {
    this.username = username;
    this.password = password;
    this.email = email;
    this.creditCard = creditCard;
    this.identity = identity;
  }

  @Override
  public String toString() {
    return Objects.toStringHelper(this)
        .add("username", username)
        .add("password", password)
        .add("email", email)
        .add("creditCard", creditCard)
        .add("identity", identity)
        .toString();
  }

  public String getUsername() {
    return username;
  }

  public void setUsername(final String username) {
    this.username = username;
  }

  @XmlTransient
  public String getPassword() {
    return password;
  }

  public void setPassword(final String password) {
    this.password = password;
  }

  public String getEmail() {
    return email;
  }

  public void setEmail(final String email) {
    this.email = email;
  }

  @XmlTransient
  public String getCreditCard() {
    return creditCard;
  }

  public void setCreditCard(final String creditCard) {
    this.creditCard = creditCard;
  }

  public Mailable getIdentity() {
    return identity;
  }

  public void setIdentity(final Mailable identity) {
    this.identity = identity;
  }
}
